<template>
  <div>
    <el-tabs @tab-click="handleClick" :stretch="true" v-model="isActive">
      <el-tab-pane label="大庆" name="大庆"></el-tab-pane>
      <el-tab-pane label="哈尔滨" name="哈尔滨"></el-tab-pane>
    </el-tabs>
    <div class="weather">
      <div class="city">
        <h2>{{ list.basic.city }} {{ list.basic.cnty }}</h2>
      </div>
      <div class="tmp">
        今天：
        {{ list.daily_forecast[0].cond.txt_d }}~
        {{ list.daily_forecast[0].cond.txt_n }}
        最高温：
        {{ list.daily_forecast[0].tmp.max }}
        最低温：
        {{ list.daily_forecast[0].tmp.min }}
      </div>
      <div class="wind">
        {{ list.daily_forecast[0].wind.dir }}
        {{ list.daily_forecast[0].wind.sc }}级
        {{ list.daily_forecast[0].wind.spd }}米每秒
      </div>
      <div class="date">{{ list.daily_forecast[0].date }}</div>
    </div>
    <el-calendar v-model="value"> </el-calendar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      value: new Date(),

      list: {},
      isActive: "大庆",
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      this.axios
        .get("https://bird.ioliu.cn/weather?city=" + this.isActive)
        .then((res) => {
          this.list = res.data;
          console.log(this.list);
          console.log(this.list.basic.city);
        });
    },
    handleClick() {
      this.getData();
    },
  },
};
</script>

<style lang="scss" scoped>
.calendar {
  > div {
    height: 50%;
  }
}
.weather {
  // height: 2rem;
  width: 100%;
  background-color: #126bbd;
  color: white;
  .tmp {
    color: orangered;
  }
  .wind {
    color: palegreen;
  }
}
</style>